﻿<%@ Page Title="Анализ :: Продажи" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Sale.aspx.cs" Inherits="Analysis.Sale" %>
<%@ Register TagName="CustomColumnDialog" Src="~/Controls/CustomColumnDialog.ascx" TagPrefix="analysis"  %>
<%@ Register TagName="ExcelImportDialog" Src="~/Controls/ExcelImportDialog.ascx" TagPrefix="analysis"  %>
<%@ Register TagName="ExcelImportErrorList" Src="~/Controls/ExcelImportErrorList.ascx" TagPrefix="analysis"  %>
<%@ Register TagName="ExcelImportColumnErrorList" Src="~/Controls/ExcelImportColumnErrorList.ascx" TagPrefix="analysis"  %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        var autoGroup = "";
        var autoSubGroup = "";

        $(function () {
            
            Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(function (evt, args) {
                $('.mightOverflow').bind('mouseenter', function () {
                    var $this = $(this);

                    if (this.offsetWidth < this.scrollWidth && !$this.attr('title')) {
                        $this.attr('title', $this.attr('data-overflow-title'));
                    }
                });
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="page_header">
        <h2><img src="<%=ResolveClientUrl("~") %>images/design/contract_tt_icon.png" alt="" title="" /> Продажи</h2>
    </div>
            
			<asp:UpdatePanel ID="upMain" runat="server" UpdateMode="Conditional">
            <ContentTemplate>

        	<div class="page_container">
                <div class="table-responsive" style="overflow-x:auto;width:100%;margin-top: -30px;">

                <asp:GridView ID="grid" AutoGenerateColumns="false" runat="server" CssClass="grid-table table table-bordered table-hover" DataKeyNames="SaleId"
                AllowSorting="true" OnSorting="grid_Sorting" 
                AllowPaging="True" PageSize="20" OnPageIndexChanging="grid_PageIndexChanging"
                OnRowDataBound="grid_RowDataBound" OnRowCommand="grid_RowCommand"
                OnRowCreated="grid_RowCreated" OnPreRender="grid_PreRender">
                <PagerSettings Mode="NumericFirstLast" PageButtonCount="4" Position="TopAndBottom" NextPageText=">" PreviousPageText="<"  FirstPageText="первая" LastPageText="последняя"/>
                <Columns>
                    <asp:TemplateField HeaderText=""> 
                        <HeaderTemplate><asp:CheckBox runat="server" ID="chbSelectAll" AutoPostBack="true" OnCheckedChanged="SelectAll_CheckedChange" /></HeaderTemplate>
                        <ItemTemplate> 
                            <asp:CheckBox runat="server" ID="chbIsSelected" Checked='<%# Bind("IsSelected") %>' AutoPostBack="true" OnCheckedChanged="selected_CheckedChange" />
                       </ItemTemplate>
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="Год"> 
                        <HeaderTemplate><asp:Label runat="server" ID="lblYearNameField" Text="YearId" Visible="false"/></HeaderTemplate> 
                        <ItemTemplate> 
                            <asp:DropDownList ID="ddlYearId" runat="server" DataTextField="YearId" DataValueField="YearId" ValidationGroup="updateItem"  CssClass="form-control"/>
                            <asp:CompareValidator id="CompareValidator1" runat="server" ControlToValidate="ddlYearId" ValidationGroup="updateItem" ErrorMessage="*" Operator="NotEqual" ValueToCompare="-1" CssClass="validation_message" Enabled="false" Display="Dynamic"/>
                        </ItemTemplate> 
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="Месяц"> 
                        <HeaderTemplate><asp:Label runat="server" ID="lblMonthNameField" Text="MonthName" Visible="false"/></HeaderTemplate> 
                        <ItemTemplate> 
                            <asp:DropDownList ID="ddlMonthId" runat="server" DataTextField="MonthName" DataValueField="MonthId" ValidationGroup="updateItem"  CssClass="form-control"/>
                            <asp:CompareValidator id="CompareValidator2" runat="server" ControlToValidate="ddlMonthId" ValidationGroup="updateItem" ErrorMessage="*" Operator="NotEqual" ValueToCompare="-1" CssClass="validation_message" Enabled="false" Display="Dynamic"/>
                        </ItemTemplate> 
                    </asp:TemplateField>
                                        
                    <asp:TemplateField HeaderText="Id TT"> 
                        <HeaderTemplate><asp:Label runat="server" ID="lblTTId" Text="TTId" Visible="false"/></HeaderTemplate> 
                        <ItemTemplate> 
                            <asp:TextBox ID="txtTTId" runat="server" Text='<%# Bind("TTId") %>' CssClass="form-control" placeholder="Введите Id TT" ValidationGroup="updateItem"></asp:TextBox> 
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator9" ControlToValidate="txtTTId" runat="server" Text="*" ValidationGroup="updateItem" CssClass="validation_message" Display="Dynamic" Enabled="false" />
                        </ItemTemplate> 
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="Id SKU">
                        <HeaderTemplate><asp:Label runat="server" ID="lblSCUIdField" Text="SCUId" Visible="false"/></HeaderTemplate> 
                        <ItemTemplate> 
                            <asp:TextBox ID="txtSCUId" runat="server" Text='<%# Bind("SCUId") %>' CssClass="form-control" placeholder="Введите Id SKU" ValidationGroup="updateItem"></asp:TextBox> 
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator6" ControlToValidate="txtSCUId" runat="server" Text="*" ValidationGroup="updateItem" CssClass="validation_message" Display="Dynamic" Enabled="false" />
                        </ItemTemplate> 
                    </asp:TemplateField>
                </Columns>
                </asp:GridView>
                </div>
                <asp:Button CssClass="btn apps_btn apps_gray_btn" ID="btnAddSale" Text="Добавить" runat="server" OnClick="btnAddSale_Click"/>
                <asp:Button CssClass="btn apps_btn apps_gray_btn" ID="btnSaveSale" Text="Сохранить изменения" runat="server" ValidationGroup="updateItem" onclick="btnSaveSale_Click" />
                <asp:Button CssClass="btn apps_btn apps_gray_btn" ID="btnDeleteSelected" Text="Удалить выбранные строки" runat="server" OnClientClick="if (Page_ClientValidate('updateItem')) {return confirm('Подтвердите удаление выбранных строк');} else {return false;}" OnClick="btnDeleteSelected_Click" />
                <asp:Button CssClass="btn apps_btn apps_gray_btn" ID="btnExcelImport" Text="Импорт из Excel" runat="server" OnClientClick="openExcelImportDialog(); return false;" />
                <asp:Button CssClass="btn apps_btn apps_gray_btn" ID="btnExcelExport" Text="Экспорт в Excel" runat="server" OnClick="btnExcelExport_Click" />
                <asp:Button CssClass="btn apps_btn apps_gray_btn" ID="btnCustomColumn" Text="Конструктор ассортимента" runat="server" OnClientClick="showCustomColumn(); return false;" Visible="False" />
            </div>
            
            </ContentTemplate>
            <Triggers>
                <asp:PostBackTrigger ControlID="btnExcelExport" />
            </Triggers>
            </asp:UpdatePanel>
            
            <analysis:CustomColumnDialog ID="ctrlCustomColumnDialog"  runat="server"  AllowAdd="true" AllowVisible="false"/>
            <analysis:ExcelImportDialog ID="ctrlExcelImportDialog"  runat="server" />
            <analysis:ExcelImportErrorList ID="ctrlExcelImportErrorList"  runat="server" />
            <analysis:ExcelImportColumnErrorList ID="ctrlExcelImportColumnErrorList"  runat="server" />
</asp:Content>
